<script type="text/javascript">
	//获取菜单树
	function returnMenuTree() {
		var data;
		$.ajax({
			url : "sys/res/menuMgr",
			type : "post",
			dataType : "json",
			data : {
				action : 'menuTree'
			},
			success : function(e) {
				data = e;
			},
			async : false
		});
		//return [{"id":1,"pid":0,"faicon":"rss","faiconClose":"cab","name":"表单元素","level":0,"tId":"menuTree_1","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":true,"isLastNode":false,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false},{"id":10,"pid":1,"url":"form-button.html","tabid":"form-button","faicon":"bell","pId":1,"name":"按钮","level":0,"tId":"menuTree_2","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":false,"isLastNode":false,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false},{"id":11,"pid":1,"url":"form-input.html","tabid":"form-input","faicon":"info-circle","pId":1,"name":"文本框","level":0,"tId":"menuTree_3","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":false,"isLastNode":false,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false},{"id":12,"pid":1,"url":"form-select.html","tabid":"form-select","faicon":"ellipsis-v","pId":1,"name":"下拉选择框","level":0,"tId":"menuTree_4","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":false,"isLastNode":false,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false},{"id":13,"pid":1,"url":"form-checkbox.html","tabid":"table","faicon":"soccer-ball-o","pId":1,"name":"复选、单选框","level":0,"tId":"menuTree_5","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":false,"isLastNode":false,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false},{"id":14,"pid":1,"url":"form.html","tabid":"form","faicon":"comments","pId":1,"name":"表单综合演示","level":0,"tId":"menuTree_6","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":false,"isLastNode":false,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false},{"id":2,"pid":0,"name":"表格","level":0,"tId":"menuTree_7","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":false,"isLastNode":false,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false},{"id":20,"pid":2,"url":"table.html","tabid":"table","faicon":"signal","pId":2,"name":"普通表格","level":0,"tId":"menuTree_8","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":false,"isLastNode":false,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false},{"id":21,"pid":2,"url":"table-fixed.html","tabid":"table-fixed","faicon":"rss-square","pId":2,"name":"固定表头表格","level":0,"tId":"menuTree_9","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":false,"isLastNode":false,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false},{"id":22,"pid":2,"url":"table-edit.html","tabid":"table-edit","faicon":"bookmark-o","pId":2,"name":"可编辑表格","level":0,"tId":"menuTree_10","parentTId":null,"open":false,"isParent":false,"zAsync":true,"isFirstNode":false,"isLastNode":true,"isAjaxing":false,"checked":false,"checkedOld":false,"nocheck":false,"chkDisabled":false,"halfCheck":false,"check_Child_State":-1,"check_Focus":false,"isHover":false,"editNameFlag":false}]
		return data;
	}
	
	//处理表格行点击事件
	function showAppConfig(id) {
		var obj = ajaxJsonSync("weixin/basedata/appConfigMgr",{action:"get",id:id});
		//设置表单值
		setFormData("#appConfig",obj);
		//设置菜单树
		initAppMenuTree(id);
		//清空表单数据
		setFormData("#appMenuForm",{});
	}
	function delAppConfig(){
		var id = $.CurrentNavtab.find("#id").val();
		if(id==null||id==""){
			$(this).alertmsg("warn","请选择要删除的配置项！");
			return;
		}
		var name = $.CurrentNavtab.find("#name").val();
		$(this).alertmsg("confirm","确认删除配置项："+name,{okCall:function(){
			var done = ajaxJsonSync("weixin/basedata/appConfigMgr",{action:"del",id:id});
			if(done&&done.statusCode==200){
				$(this).alertmsg("info",done.message);
				$.CurrentNavtab.find("#queryBtn").click();
			}else{
				$(this).alertmsg("warn",done.message);
			}
		}});
	}
	//保存用户的菜单权限配置
	function onSaveUserMenu(){
		//获取用户Id
		var userId = $.CurrentNavtab.find("#userId").val();
		if(userId){
			//获取树上选择的节点信息
			var tree = $.fn.zTree.getZTreeObj("userMenuTree");
			var nodes = tree.getCheckedNodes(true);
			//获取Id数组
			var ids = new Array();
			for(var i=0; i<nodes.length; i++){
				ids.push(nodes[i].id);
			}
			//发送数据到后台进行保存
			var r = ajaxJsonSync("sys/user/userMenuMgr",{action:"saveUserMenu",userId:userId,menuId:ids.toString()});
			$(this).alertmsg("info",r.message);
		}else{
			$(this).alertmsg("warn","请选择要配置的用户！");
		}
	}
</script>
<div class="bjui-pageContent  tableContent">
	<div style="padding: 1%; width: 35%; float: left; height: 100%;">
        <fieldset style="width: 100%;height:100%;padding:0;overflow:auto;">
        	<legend>公众号列表</legend>
            <#include "appList.html">
    	</fieldset>
    </div>
	<div style="padding: 1%; width: 64%; float: left; height: 100%;">
		<input type="hidden" id="userId"/>
		<fieldset style="height: 100%; overflow: auto;">
			<legend>公众号配置</legend>
			<!-- Tabs -->
            <ul class="nav nav-tabs" role="tablist">
                <li class="active"><a href="#div_appconfig" role="tab" data-toggle="tab">配置信息</a></li>
                <li><a href="#div_appmenu" role="tab" data-toggle="tab">菜单</a></li>
            </ul>
            <!-- Tab panes -->
            <div class="tab-content" style="height:88%">
            	<div class="tab-pane fade active in" id="div_appconfig">
            	<form action="weixin/basedata/appConfigMgr?action=save" id="appConfig" data-toggle="ajaxform" data-alertmsg="false">
            		<input type="hidden" name="id" value="" id="id">
            		<table class="table table-condensed" width="100%">
            		<tbody>
            			<tr>
	            			<td>
	                        <label for="name" class="control-label x110">名称：</label>
	                        <input type="text" name="name" id="name" value="" data-rule="required" size="40">
	                   		</td>
                   		</tr>
                   		<tr>
	            			<td>
	                        <label for="appId" class="control-label x110">appID：</label>
	                        <input type="text" name="appId" id="appId" value="" data-rule="required" size="40">
	                   		</td>
                   		</tr>
                   		<tr>
	            			<td>
	                        <label for="appsecret" class="control-label x110">appsecret：</label>
	                        <input type="text" name="appsecret" id="appsecret" value="" data-rule="required" size="50">
	                   		</td>
                   		</tr>
                   		<tr>
	            			<td>
	                        <label for="aseKey" class="control-label x110">aesKey：</label>
	                        <input type="text" name="aseKey" id="aseKey" value=""  size="40">
	                   		</td>
                   		</tr>
                   		<tr>
	            			<td>
	                        <label for="mappingUrl" class="control-label x110">location URL：</label>
	                        <input type="text" name="mappingUrl" id="mappingUrl" value="" data-rule="required" size="40">
	                   		</td>
                   		</tr>
                   		<tr>
	            			<td>
	                        <label for="token" class="control-label x110">Token：</label>
	                        <input type="text" name="token" id="token" value="" data-rule="required" size="40">
	                   		</td>
                   		</tr>
	                	<tr>
	                		<td>
                        		<label for="" class="control-label x110">测试账号：</label>
                        		<input type="radio" name="testAccount" id="testAccount1" data-toggle="icheck" value="T" checked data-label="<span style='color:red;'>是</span>">
                        		&nbsp;&nbsp;
                        		<input type="radio" name="testAccount" id="testAccount2" data-toggle="icheck" value="F" data-label="否">
                    		</td>
	                	</tr>
	                	<tr>
	                    <td>
	                        <label for="description" class="control-label x110">应用描述：</label>
	                        <textarea name="description" id="description" data-toggle="autoheight" cols="50" rows="5"></textarea>
	                    </td>
	                    </tr>
	                    <tr>
	                    	<td align="center" style="height:50px;">
	                    		<button type="submit" class="btn-default" data-icon="save">保存</button>
	                    		&nbsp;&nbsp;
	                    		<button type="button" class="btn-default" data-icon="remove" onclick="delAppConfig();">删除</button>
	                    	</td>
	                    </tr>
                    </tbody>
            		</table>
            	</form>
            	</div>
            	<div class="tab-pane fade" id="div_appmenu">
            		<#include "appMenu.html">
            	</div>
            </div>
		</fieldset>
	</div>
</div>